package com.example.demo.mapper;

import com.example.demo.controller.vo.OrderDetailVo;
import com.example.demo.entity.OrderPO;
import com.example.demo.entity.UserOrder;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Repository;
import org.springframework.web.bind.annotation.PostMapping;

import java.util.List;
import java.util.Set;

//用户拼团数据库操作

@Mapper

public interface UserOrderMapper {

    @Select("select * from tb_user_order where userId = #{userId} and status = #{status} ")
    List<UserOrder> selectOrderList(@Param("userId") String userId, @Param("status") int status);

    @Select("select orderId from tb_user_order where status = #{status} and courseId = #{courseId} and userId = #{userId} ")
    Long selectOrderByStatus(@Param("status") Integer status,
                                   @Param("userId") String userId,
                                   @Param("courseId") long courseId);

    @Update("update tb_user_order set status = #{status} where orderId = #{orderId} ")
    void updateOrderStatus(@Param("orderId") Long orderIdList,@Param("status") Integer status);

    @Insert("insert into tb_user_order (userId,orderId,status,createTime,updateTime,courseId) values(#{userId} ,#{orderId} ,#{status} ,#{createTime} ,#{updateTime} ,#{courseId} )")
    void add(UserOrder userOrder);

    @Select("select * from tb_user_order where userId = #{userId} ")
    List<UserOrder> selectOrderList1(String userId);

    @Update("update tb_user_order set status = #{pintuanFail} where userId = #{userId} and courseId = #{courseId} and status = #{pintuanReady} ")
    void updateOrderStatusByStatusAndUserIdAndCourseId(@Param("userId") String userId,
                                                       @Param("pintuanReady") Integer pintuanReady,
                                                       @Param("courseId") long courseId,
                                                       @Param("pintuanFail") Integer pintuanFail);
}
